package com.yf.dxapp.module.app.dal.mysql.category;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import com.yf.dxapp.module.app.controller.admin.category.vo.CategoryPageReqVO;
import com.yf.dxapp.module.app.dal.dataobject.category.CategoryDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 分类信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CategoryMapper extends BaseMapperX<CategoryDO> {

    default PageResult<CategoryDO> selectPage(CategoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CategoryDO>()
                .eqIfPresent(CategoryDO::getType, reqVO.getType())
                .likeIfPresent(CategoryDO::getName, reqVO.getName())
                .eqIfPresent(CategoryDO::getLevel, reqVO.getLevel())
                .eqIfPresent(CategoryDO::getRootId, reqVO.getRootId())
                .eqIfPresent(CategoryDO::getRemark, reqVO.getRemark())
                .eqIfPresent(CategoryDO::getParentType, reqVO.getParentType())
                .betweenIfPresent(CategoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CategoryDO::getId));
    }

}